package com.square.service.common.handler;

import com.baomidou.mybatisplus.extension.api.IErrorCode;
import com.square.service.common.consts.GlobalStatusCode;

/**
 * @author : 18.40
 * @date : 2020/8/11 12:35
 * @description : 通用返回码
 */
public enum ApiCode implements IErrorCode {

    //响应
    SUCCESS(GlobalStatusCode.SUCCESS, "执行成功"),
    FAILED(GlobalStatusCode.FAILED, "操作失败"),
    NOT_FOUND(GlobalStatusCode.NOT_FOUND, "未找到该资源"),
    PARAMETER_NULL_POINT_EXCEPTION(GlobalStatusCode.PARAMETER_NULL_POINT_EXCEPTION, "参数空指针"),
    RESULT_NULL_POINT_EXCEPTION(GlobalStatusCode.RESULT_NULL_POINT_EXCEPTION, "结果集空指针"),
    INTERNAL_SERVER_ERROR(GlobalStatusCode.INTERNAL_SERVER_ERROR, "服务器内部错误"),
    DATABASE_EXCEPTION(GlobalStatusCode.DATABASE_EXCEPTION, "数据库异常"),

    INVALID_TOKEN(GlobalStatusCode.UNAUTHORIZED, "无效令牌，请重新登录"),
    INVALID_PERMISSION(GlobalStatusCode.UNAUTHORIZED, "无此权限，请联系管理员授权"),
    INVALID_PROXY(GlobalStatusCode.PROXY_AUTHENTICATION_REQUIRED, "需要代理身份验证"),

    REDIS_SERVICE_EXCEPTION(GlobalStatusCode.SERVICE_EXCEPTION, "Redis微服务异常"),
    MEMBER_SERVICE_EXCEPTION(GlobalStatusCode.SERVICE_EXCEPTION, "用户微服务异常"),
    AUTH_SERVICE_EXCEPTION(GlobalStatusCode.SERVICE_EXCEPTION, "认证微服务异常");


    private final long code;
    private final String msg;

    ApiCode(long code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public long getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.msg;
    }
}
